define(["jquery", "easy-admin"], function ($, ea) {

    var init = {
        table_elem: '#currentTable',
        table_render_id: 'currentTableRenderId',
        index_url: 'store.exchange/index',
        add_url: 'store.exchange/add',
        edit_url: 'store.exchange/edit',
        delete_url: 'store.exchange/delete',
        export_url: 'store.exchange/export',
        modify_url: 'store.exchange/modify',
    };

    var Controller = {

        index: function () {
            ea.table.render({
                init: init,
                cols: [[
                    {type: 'checkbox'},
                    {field: 'id', title: '主键id'},
                    {field: 'goods_id', title: '商品名称',templet: function (res) {
                            return "<label>"+res.getGoodsInfo.goods_name+"</label>"
                        }},
                    {field: 'need_integral', title: '需要积分'},
                    {field: 'stock', title: '库存'},
                    {field: 'is_status', search: 'select', selectList: {1: '上架', 0: '下架'}, title: '是否上架', templet: ea.table.switch},
                    {field: 'create_time', title: '添加时间'},
                    {width: 130, title: '操作', templet: ea.table.tool},

                ]],
            });

            ea.listen();
        },
        add: function () {
            ea.listen();
        },
        edit: function () {
            ea.listen();
        },
    };
    return Controller;
});